<?php
namespace MyExt;
require './ThinkPHP/Library/MyExt/Upyun/vendor/autoload.php';
use Upyun\Config;
use Upyun\Upyun;
class MyUpyun{
	public $obj_upyun = '';
	public $obj_config = '';
	public function __construct(){
		if($this->obj_upyun == ''){
			$this->obj_config = new Config('fang-images','tpcwre','xiaodong123');
			$this->obj_upyun = new Upyun($this->obj_config);
		}
	}


	/*
		上传文件
		$path 	string 		路径带文件名。如： /dir/filename.png
		$res 	stream | string 		文件流或字符串
	*/
	public function add($path,$res){
		return $info = $this->obj_upyun->write($path,$res);
	}






	/*
		删除文件或目录
		$path 	string 		路径或路径加文件全名
		$async  bool 		是否异步处理，true 为异步

	*/
	public function delete($path, $async = false){
		return $info = $this->obj_upyun->delete($path, $async);
	}
}